package com.base.study03_enum;

import java.util.EnumMap;
import java.util.EnumSet;
import java.util.Map;
import java.util.Set;

/**
 * ClassName: EnumSetTest
 * PackageName: com.cwy.study03_enum
 * Describe:
 *
 * @author: Cheng Wenying
 * @Create: 2024/1/11
 * @version:
 */
public class EnumSetTest {

    public static void main(String[] args) {
        EnumSet<PlayerType> playerTypes = EnumSet.noneOf(PlayerType.class);
        System.out.println(playerTypes);

        EnumSet<PlayerType> playerTypes1 = EnumSet.allOf(PlayerType.class);
        System.out.println(playerTypes1);

        EnumMap<PlayerType, String> enumMap = new EnumMap<>(PlayerType.class);
        enumMap.put(PlayerType.BASKETBALL, "篮球运动员");
        enumMap.put(PlayerType.FOOTBALL, "足球运动员");
        enumMap.put(PlayerType.TENNIS, "网球运动员");
        // 遍历map 有三种方式  第一个是entryset()方法；第二个是遍历map的key有keyset()，遍历map的value有values(),第三种方法是iterator迭代器，第四种方法是lambda表达式
        Set<Map.Entry<PlayerType, String>> entries = enumMap.entrySet();
        for (Map.Entry<PlayerType, String> item : entries) {
            System.out.println(item.getKey() + "," + item.getValue());
        }
        System.out.println("----------------");
        enumMap.forEach((key, value) -> {
            System.out.println(key + "," + value);
        });
    }
}
